package com.wangjiacai.hqlQuery.role.controller;

import com.wangjiacai.hqlQuery.role.entity.Function;
import com.wangjiacai.hqlQuery.role.service.FunctionService;
import com.wangjiacai.hqlQuery.role.service.TokenUserService;
import com.wangjiacai.utils.output.ResultVO;
import com.wangjiacai.utils.utils.ResultVOUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class CommonUserController {

    @Autowired
    private FunctionService functionService;
    @Autowired
    private TokenUserService tokenUserService;

    @GetMapping("/function")
    public ResultVO getUserFunction(@RequestHeader("token")String token){
        String userId=tokenUserService.findUserId(token);
        List<Function> list=functionService.findFunctionByUserId(userId);
        return ResultVOUtil.success(list);

    }
}
